package cn.hy.face.module.business.controller;

import cn.hy.face.common.service.FaceRecognitionService;
import cn.hy.face.common.vo.*;
import cn.hy.face.common.vo.UsersQueryVO;
import org.apache.thrift.TException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * @program: face
 * @author: qingxiangen
 * @create: 2019-09-04 11:47
 * @description: 人脸识别管理功能 Controller
 **/
@RestController
@RequestMapping("/facerecognition")
public class FaceRecognitionController {

    /**
     * 人脸识别服务
     */
    @Autowired
    private FaceRecognitionService faceRecognitionService;

    /**
     * 根据学校id获取所有年级及班级信息
     * @param schoolId 学校id
     */
    @RequestMapping("/getOfficeList")
    public Result getOfficeList(@RequestParam String schoolId) throws Exception {
        List<BusiGradeVO> gradeList = faceRecognitionService.getOfficeList(schoolId);
        return Result.success(gradeList);
    }

    /**
     * 根据班级id及查询条件获取班级中的学生信息
     * @param queryVO 查询条件
     */
    @RequestMapping("/getUsersByClassId")
    public Result getUsersByClassId(UsersQueryVO queryVO) throws Exception {
        PageInfo<SysStudentVO> pageInfo = faceRecognitionService.getUsersByClassId(queryVO);
        return Result.success(pageInfo);
    }

    /**
     * 更新人脸照片信息
     * @param schoolId 学校id
     * @param userId 学生id
     * @param facePhoto 人脸照片URL
     * @return
     * @throws TException
     */
    @RequestMapping("/updateFacePhoto")
    public Result updateFacePhoto(@RequestParam String schoolId, @RequestParam String classId, @RequestParam String userId, @RequestParam String facePhoto) throws TException {
        faceRecognitionService.updateFacePhoto(schoolId, classId, userId, facePhoto);
        return Result.success(null);
    }
}
